package com.goods.controller.business;

import com.goods.business.service.ConsumerService;
import com.goods.business.service.ProductCategoryService;
import com.goods.common.model.business.Consumer;
import com.goods.common.model.business.Supplier;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.ConsumerVO;
import com.goods.common.vo.business.InStockVO;
import com.goods.common.vo.business.ProductCategoryTreeNodeVO;
import com.goods.common.vo.business.SupplierVO;
import com.goods.common.vo.system.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 赵勇镔
 * @Time: 2021/6/10 14:35
 * @Description:
 */

//business/consumer/findConsumerList?pageNum=1&pageSize=10&name= 404

@Api(tags = "业务模块-物资去处")
@RestController
@RequestMapping("/business/consumer")
public class ConsumerController {


    @Autowired
    private ConsumerService consumerService;


    @ApiOperation(value = "物资去处", notes = "去处信息展示")
    @GetMapping("/findConsumerList")
    public ResponseBean<PageVO<ConsumerVO>> findConsumerList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                            @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                            ConsumerVO consumerVO) {
        PageVO<ConsumerVO> pageVO = consumerService.findConsumerList(pageNum,pageSize,consumerVO);
        return ResponseBean.success(pageVO);
    }

    @ApiOperation(value = "物资去处", notes = "去处信息添加")
    @PostMapping("/add")
    public ResponseBean add(@RequestBody ConsumerVO consumerVO) {
        consumerService.add(consumerVO);
        return ResponseBean.success();
    }
    @ApiOperation(value = "物资去处", notes = "数据回显")
    @GetMapping("/edit/{id}")
    public ResponseBean<ConsumerVO> edit(@PathVariable  Long id){
        ConsumerVO consumerVO = consumerService.edit(id);
        return ResponseBean.success(consumerVO);
    }


    @ApiOperation(value = "物资去处", notes = "数据保存")
    @PutMapping("/update/{id}")
    public ResponseBean update(@PathVariable  Long id,@RequestBody ConsumerVO consumerVO){
        consumerService.update(id,consumerVO);
        return ResponseBean.success();
    }

    @ApiOperation(value = "物资去处", notes = "删除信息")
    @DeleteMapping("/delete/{id}")
    public ResponseBean delete(@PathVariable  Long id){
        consumerService.delete(id);
        return ResponseBean.success();
    }


}
